#!/bin/bash

# 测试数据生成脚本

TEST_DIR="/data/sync/test"

echo "开始生成测试数据..."

# 生成org_unit.txt
cat > $TEST_DIR/org_unit.txt << 'EOF'
id|name|c_code|parent_id|create_time|update_time
org-001|技术部|TECH001||2024-01-01 10:00:00|2024-01-01 10:00:00
org-002|研发中心|TECH002|org-001|2024-01-01 10:00:00|2024-01-01 10:00:00
org-003|测试部|TECH003|org-001|2024-01-01 10:00:00|2024-01-01 10:00:00
org-004|产品部|PROD001||2024-01-01 10:00:00|2024-01-01 10:00:00
org-005|设计组|PROD002|org-004|2024-01-01 10:00:00|2024-01-01 10:00:00
EOF

# 生成employee.txt
cat > $TEST_DIR/employee.txt << 'EOF'
id|user_code|c_org_id|c_org_code|c_org_name|create_time
emp-001|USER001|org-001|TECH001|技术部|2024-01-01 10:00:00
emp-002|USER002|org-002|TECH002|研发中心|2024-01-01 10:00:00
emp-003|USER003|org-002|TECH002|研发中心|2024-01-01 10:00:00
emp-004|USER004|org-003|TECH003|测试部|2024-01-01 10:00:00
emp-005|USER005|org-004|PROD001|产品部|2024-01-01 10:00:00
emp-006|USER006|org-005|PROD002|设计组|2024-01-01 10:00:00
EOF

# 生成org_unit.json
cat > $TEST_DIR/org_unit.json << 'EOF'
[
  {"id": "org-101", "name": "销售部", "cCode": "SALE001", "parentId": null},
  {"id": "org-102", "name": "华东区", "cCode": "SALE002", "parentId": "org-101"},
  {"id": "org-103", "name": "华北区", "cCode": "SALE003", "parentId": "org-101"}
]
EOF

# 生成employee.json
cat > $TEST_DIR/employee.json << 'EOF'
[
  {"id": "emp-101", "userCode": "SALE001", "cOrgId": "org-101", "cOrgCode": "SALE001", "cOrgName": "销售部"},
  {"id": "emp-102", "userCode": "SALE002", "cOrgId": "org-102", "cOrgCode": "SALE002", "cOrgName": "华东区"},
  {"id": "emp-103", "userCode": "SALE003", "cOrgId": "org-103", "cOrgCode": "SALE003", "cOrgName": "华北区"}
]
EOF

echo "测试数据生成完成！"
echo "----------------------------------------"
ls -lh $TEST_DIR
echo "----------------------------------------"
